<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Pager template
 *
 * @see \Magento\Theme\Block\Html\Pager
 */
?>
<?php if($this->getCollection()->getSize()): ?>

    <?php if($this->getUseContainer()): ?>
    <div class="pager">
    <?php endif ?>

        <?php if($this->getShowAmounts()): ?>
        <p class="toolbar-amount">
            <span class="toolbar-number">
            <?php if($this->getLastPageNum()>1): ?>
                <?php echo __('Items %1 to %2 of %3 total', $this->getFirstNum(), $this->getLastNum(), $this->getTotalNum()) ?>
            <?php elseif ($this->getLastPageNum() == 1): ?>
                <?php echo __('%1 Item', $this->getTotalNum()) ?>
            <?php else: ?>
                <?php echo __('%1 Item(s)', $this->getTotalNum()) ?>
            <?php endif; ?>
            </span>
        </p>
        <?php endif ?>

        <?php if($this->getLastPageNum()>1): ?>
        <div class="pages">
            <strong class="label pages-label" id="paging-label"><?php echo __('Page') ?></strong>
            <ul class="items pages-items" aria-labelledby="paging-label">
            <?php if (!$this->isFirstPage()): ?>
                <li class="item pages-item-previous">
                    <?php $text = $this->getAnchorTextForPrevious() ? $this->getAnchorTextForPrevious() : '';?>
                    <a class="<?php echo $text ? 'link ' : 'action '?> previous" href="<?php echo $this->getPreviousPageUrl() ?>" title="<?php echo $text ? $text : __('Previous') ?>">
                        <span class="label"><?php echo __('Page') ?></span>
                        <span><?php echo $text ? $text : __('Previous') ?></span>
                    </a>
                </li>
            <?php endif;?>

            <?php if ($this->canShowFirst()): ?>
                <li class="item">
                    <a class="page first" href="<?php echo $this->getFirstPageUrl() ?>">
                        <span class="label"><?php echo __('Page') ?></span>
                        <span>1</span>
                    </a>
                </li>
            <?php endif;?>

            <?php if ($this->canShowPreviousJump()): ?>
                <li class="item">
                    <a class="page previous jump" title="" href="<?php echo $this->getPreviousJumpUrl() ?>">
                        <span>...</span>
                    </a>
                </li>
            <?php endif;?>

            <?php foreach ($this->getFramePages() as $_page): ?>
                <?php if ($this->isPageCurrent($_page)): ?>
                    <li class="item current">
                        <strong class="page">
                            <span class="label"><?php echo __('You\'re currently reading page') ?></span>
                            <span><?php echo $_page ?></span>
                        </strong>
                    </li>
                <?php else: ?>
                    <li class="item">
                        <a href="<?php echo $this->getPageUrl($_page) ?>" class="page">
                            <span class="label"><?php echo __('Page') ?></span>
                            <span><?php echo $_page ?></span>
                        </a>
                    </li>
                <?php endif;?>
            <?php endforeach;?>

            <?php if ($this->canShowNextJump()): ?>
                <li class="item">
                    <a class="page next jump" title="" href="<?php echo $this->getNextJumpUrl() ?>">
                        <span>...</span>
                    </a>
                </li>
            <?php endif;?>

            <?php if ($this->canShowLast()): ?>
              <li class="item">
                  <a class="page last" href="<?php echo $this->getLastPageUrl() ?>">
                      <span class="label"><?php echo __('Page') ?></span>
                      <span><?php echo $this->getLastPageNum() ?></span>
                  </a>
              </li>
            <?php endif;?>

            <?php if (!$this->isLastPage()): ?>
                <li class="item pages-item-next">
                    <?php $text = $this->getAnchorTextForNext() ? $this->getAnchorTextForNext() : '';?>
                    <a class="<?php echo $text ? 'link ' : 'action '?> next" href="<?php echo $this->getNextPageUrl() ?>" title="<?php echo $text ? $text : __('Next') ?>">
                        <span class="label"><?php echo __('Page') ?></span>
                        <span><?php echo $text ? $text : __('Next') ?></span>
                    </a>
                </li>
            <?php endif;?>
            </ul>
        </div>
        <?php endif; ?>

        <?php if($this->isShowPerPage()): ?>
            <div class="limiter">
                <strong class="limiter-label"><?php echo __('Show') ?></strong>
                <select id="limiter" data-mage-redirect="{'event':'change'}" class="limiter-options">
                    <?php foreach ($this->getAvailableLimit() as $_key => $_limit): ?>
                    <option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if ($this->isLimitCurrent($_key)): ?>
                            selected="selected"<?php endif ?>>
                        <?php echo $_limit ?>
                    </option>
                    <?php endforeach; ?>
                </select>
                <span class="limiter-text"><?php echo __('per page') ?></span>
            </div>
        <?php endif ?>

    <?php if($this->getUseContainer()): ?>
    </div>
    <?php endif ?>

<?php endif ?>
